<template>
  <div>
    <table>
      <sale
        v-for="(item, index) in goodsArr"
        :key="index"
        :fruits="item"
      ></sale>
    </table>
    <div>Total:{{ total }}</div>
  </div>
</template>

<script>
import sale from "./components/Sale";
export default {
  components: {
    sale,
  },
  computed: {
    total() {
      return this.goodsArr.reduce((sum, current) => {
        return sum + current.count;
      }, 0);
    },
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
};
</script>

<style>
</style>